import Router from '@koa/router'
import { apiAudit } from '../middleware/api-audit.mjs'
import { auth } from '../middleware/auth.mjs'
import { authRouter } from './auth.mjs'
import { deviceRouter } from './device.mjs'

export const router = new Router()

router.get('/healthz', (ctx) => {
  ctx.body = {
    success: true,
    msg: 'ok',
    data: null
  }
})

router.use(apiAudit)
router.use('/api/v1/auth', authRouter.routes(), authRouter.allowedMethods())
router.use(auth)
router.use('/api/v1/device', deviceRouter.routes(), deviceRouter.allowedMethods())
